﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Unimaq.FacturaDBS_Spring.LogicaNegocio.CentroCosto.UC
{
    public class DBS_LineAD_ObjectDLL
    {
        public void Convertir(Entidades.CentroCosto.UC.DBS_Head_Detail_Factura_UCRepuestos facturaDetalle)
        {
            string line = facturaDetalle.Linead;

            if (!string.IsNullOrWhiteSpace(line))
            {
                facturaDetalle.DetalleLineAD.Ped = !string.IsNullOrWhiteSpace(line.Substring(0,5)) ? int.Parse(line.Substring(0,5)) : 0;
                facturaDetalle.DetalleLineAD.Ent = !string.IsNullOrWhiteSpace(line.Substring(5,5)) ? int.Parse(line.Substring(5,5)) : 0;
                facturaDetalle.DetalleLineAD.Pro = line.Substring(10,4).Trim();
                facturaDetalle.DetalleLineAD.NroParte = line.Substring(14,22).Trim();
                facturaDetalle.DetalleLineAD.Descripcion = line.Substring(36,24).Trim();
                facturaDetalle.DetalleLineAD.ValorVenta = !string.IsNullOrWhiteSpace(line.Substring(60,9)) ? decimal.Parse(line.Substring(60,9)) : new decimal(0);
                facturaDetalle.DetalleLineAD.PorcDscto = !string.IsNullOrWhiteSpace(line.Substring(69,12)) ? decimal.Parse(line.Substring(69,12)) : new decimal(0);
                facturaDetalle.DetalleLineAD.ValorDscto = !string.IsNullOrWhiteSpace(line.Substring(81,16)) ? decimal.Parse(line.Substring(81,16)) : new decimal(0);
                facturaDetalle.DetalleLineAD.ValorVentaNetoUnitario = !string.IsNullOrWhiteSpace(line.Substring(97,15)) ? decimal.Parse(line.Substring(97,15)) : new decimal(0);
                facturaDetalle.DetalleLineAD.ValorVentaTotal = !string.IsNullOrWhiteSpace(line.Substring(112, 15)) ? decimal.Parse(line.Substring(112, 15)) : new decimal(0);
                facturaDetalle.DetalleLineAD.Campo1 = line.Substring(127, 5);
            }
        }
    }
}
